home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / vb / jstick.exe / JSTICK.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-04-18  |  7.3 KB  |  244 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Stick of Joy"
  5.    Height          =   3240
  6.    Icon            =   JSTICK.FRX:0000
  7.    Left            =   1080
  8.    LinkTopic       =   "Form1"
  9.    MaxButton       =   0   'False
  10.    ScaleHeight     =   2865
  11.    ScaleWidth      =   3270
  12.    Top             =   1680
  13.    Width           =   3360
  14.    Begin Timer Timer2 
  15.       Interval        =   1000
  16.       Left            =   0
  17.       Top             =   240
  18.    End
  19.    Begin PictureBox Picture1 
  20.       Height          =   495
  21.       Index           =   2
  22.       Left            =   2760
  23.       Picture         =   JSTICK.FRX:0302
  24.       ScaleHeight     =   465
  25.       ScaleWidth      =   465
  26.       TabIndex        =   15
  27.       Top             =   1680
  28.       Visible         =   0   'False
  29.       Width           =   495
  30.    End
  31.    Begin PictureBox Picture1 
  32.       Height          =   495
  33.       Index           =   1
  34.       Left            =   2760
  35.       Picture         =   JSTICK.FRX:0604
  36.       ScaleHeight     =   465
  37.       ScaleWidth      =   465
  38.       TabIndex        =   14
  39.       Top             =   2040
  40.       Visible         =   0   'False
  41.       Width           =   495
  42.    End
  43.    Begin PictureBox Picture1 
  44.       Height          =   495
  45.       Index           =   0
  46.       Left            =   2760
  47.       Picture         =   JSTICK.FRX:0906
  48.       ScaleHeight     =   465
  49.       ScaleWidth      =   465
  50.       TabIndex        =   13
  51.       Top             =   2280
  52.       Visible         =   0   'False
  53.       Width           =   495
  54.    End
  55.    Begin Frame Frame2 
  56.       Caption         =   "Reading"
  57.       Height          =   855
  58.       Left            =   1680
  59.       TabIndex        =   8
  60.       Top             =   720
  61.       Width           =   1335
  62.       Begin OptionButton Option4 
  63.          Caption         =   "BIOS"
  64.          Height          =   255
  65.          Left            =   120
  66.          TabIndex        =   10
  67.          Top             =   480
  68.          Width           =   1095
  69.       End
  70.       Begin OptionButton Option3 
  71.          Caption         =   "Hardware"
  72.          Height          =   255
  73.          Left            =   120
  74.          TabIndex        =   9
  75.          Top             =   240
  76.          Value           =   -1  'True
  77.          Width           =   1095
  78.       End
  79.    End
  80.    Begin Frame Frame1 
  81.       Caption         =   "    Joystick selection"
  82.       Height          =   615
  83.       Left            =   120
  84.       TabIndex        =   5
  85.       Top             =   0
  86.       Width           =   3015
  87.       Begin OptionButton Option2 
  88.          Caption         =   "Number 2"
  89.          Height          =   255
  90.          Left            =   1560
  91.          TabIndex        =   7
  92.          Top             =   240
  93.          Width           =   1335
  94.       End
  95.       Begin OptionButton Option1 
  96.          Caption         =   "Number 1"
  97.          Height          =   255
  98.          Left            =   120
  99.          TabIndex        =   6
  100.          Top             =   240
  101.          Value           =   -1  'True
  102.          Width           =   1215
  103.       End
  104.    End
  105.    Begin CommandButton Command1 
  106.       Cancel          =   -1  'True
  107.       Caption         =   "&Exit"
  108.       Default         =   -1  'True
  109.       Height          =   375
  110.       Left            =   2040
  111.       TabIndex        =   4
  112.       Top             =   2400
  113.       Width           =   735
  114.    End
  115.    Begin CheckBox button2_j1_hard 
  116.       Caption         =   "Button #2"
  117.       Height          =   255
  118.       Left            =   1680
  119.       TabIndex        =   2
  120.       Top             =   2040
  121.       Width           =   255
  122.    End
  123.    Begin CheckBox button1_j1_hard 
  124.       Caption         =   "Button #1"
  125.       Height          =   255
  126.       Left            =   1680
  127.       TabIndex        =   1
  128.       Top             =   1800
  129.       Width           =   255
  130.    End
  131.    Begin PictureBox crosshair 
  132.       BorderStyle     =   0  'None
  133.       Enabled         =   0   'False
  134.       Height          =   420
  135.       Left            =   0
  136.       Picture         =   JSTICK.FRX:0C08
  137.       ScaleHeight     =   420
  138.       ScaleWidth      =   420
  139.       TabIndex        =   0
  140.       Top             =   1080
  141.       Width           =   420
  142.    End
  143.    Begin Timer Timer1 
  144.       Interval        =   100
  145.       Left            =   0
  146.       Top             =   1560
  147.    End
  148.    Begin Label Label2 
  149.       Caption         =   "Button #2"
  150.       Height          =   255
  151.       Left            =   1920
  152.       TabIndex        =   12
  153.       Top             =   2040
  154.       Width           =   1215
  155.    End
  156.    Begin Label Label1 
  157.       Caption         =   "Button #1"
  158.       Height          =   255
  159.       Left            =   1920
  160.       TabIndex        =   11
  161.       Top             =   1800
  162.       Width           =   1095
  163.    End
  164.    Begin Label Label3 
  165.       Caption         =   "Label3"
  166.       Height          =   255
  167.       Left            =   240
  168.       TabIndex        =   3
  169.       Top             =   2520
  170.       Width           =   1335
  171.    End
  172.    Begin Shape Shape1 
  173.       BorderWidth     =   3
  174.       Height          =   1455
  175.       Left            =   120
  176.       Shape           =   4  'Rounded Rectangle
  177.       Top             =   960
  178.       Width           =   1455
  179.    End
  180. Option Explicit
  181. Declare Function jstick Lib "JSTICK.DLL" Alias "#2" (ByVal method As Integer, ByVal jstick_num As Integer, xcord As Integer, ycord As Integer, but1 As Integer, but2 As Integer) As Integer
  182. Dim xcord As Integer
  183. Dim ycord As Integer
  184. Dim but1 As Integer
  185. Dim but2 As Integer
  186. Dim method As Integer
  187. Dim joystick As Integer
  188. Sub Command1_Click ()
  189.    End
  190. End Sub
  191. Sub Form_Load ()
  192.    joystick = 1
  193.    method = 0
  194. End Sub
  195. Sub Option1_Click ()
  196.    If option1.Value = True Then joystick = 1
  197. End Sub
  198. Sub Option2_Click ()
  199.    If option2.Value = True Then joystick = 2
  200. End Sub
  201. Sub Option3_Click ()
  202.    If option3.Value = True Then method = 0
  203. End Sub
  204. Sub Option4_Click ()
  205.    If option4.Value = True Then method = 1
  206. End Sub
  207. Sub Timer1_Timer ()
  208.    'If window is open then do joystick routine
  209.    If form1.WindowState = 0 Then
  210.       'Read joystick settings using jstick call to DLL
  211.       If jstick(method, joystick, xcord, ycord, but1, but2) Then
  212.       
  213.          'Show returned x & y coordinates
  214.          label3.Caption = "X:" + LTrim(Str(xcord)) + "  Y:" + LTrim(Str(ycord))
  215.       
  216.          'Set coordinates for near center for joystick 1 & hardware
  217.          xcord = xcord * 2
  218.          ycord = ycord * 2.4
  219.       
  220.          'Keep crosshare on target area
  221.          If xcord > shape1.Width - shape1.Left Then xcord = shape1.Width - shape1.Left - 200
  222.          If ycord > shape1.Height + shape1.Top Then ycord = shape1.Height - shape1.Top - 200
  223.       
  224.          'Move crosshare to new values
  225.          crosshair.Left = shape1.Left + xcord
  226.          crosshair.Top = shape1.Top + ycord
  227.          'show buttons being pushed
  228.          button1_j1_hard.Value = 1 - but1
  229.          button2_j1_hard.Value = 1 - but2
  230.       End If
  231.    End If
  232. End Sub
  233. Sub Timer2_Timer ()
  234.    Static index As Integer
  235.    'If form minimized then change icon
  236.    If form1.WindowState = 1 Then
  237.       If index > 2 Then index = 0
  238.       
  239.       'load icon that matches index
  240.       form1.Icon = picture1(index).Picture
  241.       index = index + 1
  242.    End If
  243. End Sub
  244.